package com.sp.utils;

import com.sp.model.entity.Employee;

/**
 * @author tong
 * @date 2024/4/4 15:51
 */
public class EmployeeThreadLocal {

    private static final ThreadLocal<Employee> EMPLOYEE_THREAD_LOCAL = new ThreadLocal<>();

    public static void setEmployee(Integer id, String name) {
        Employee employee = new Employee();
        employee.setId(id);
        employee.setUsername(name);
        EMPLOYEE_THREAD_LOCAL.set(employee);
    }

    public static Employee getEmployee() {
        return EMPLOYEE_THREAD_LOCAL.get();
    }

    public static void removeEmployee() {
        EMPLOYEE_THREAD_LOCAL.remove();
    }

}
